import {NavBar} from "antd-mobile";
import {useNavigate} from "react-router-dom";
import styles from './index.module.css'
import PropTypes from 'prop-types';

const NavHeader = ({children, onBack}) => {

    // 路由跳转hook
    const navigate = useNavigate();
    const back = () => {
        navigate(-1)
    }

    // 添加组件校验
    NavHeader.propTypes = {
        children: PropTypes.string.isRequired,
        onBack: PropTypes.func
    }

    return <NavBar className={styles.navbar} onBack={onBack || back}>{children}</NavBar>;
}

export {NavHeader}